package com.util;

import org.apache.commons.lang3.LocaleUtils;

import java.text.DateFormat;
import java.text.NumberFormat;
import java.util.Date;
import java.util.Locale;

/**
 * @Author:zxh
 * @Description: Locale对象代表具体的地理，政治或文化地区
 * @Date: 2020/10/13
 * @Modified By:
 */
class LocaleTest {
    public static void test() {
        Locale zh_cn = new Locale("zh_CN");

        Locale aDefault = Locale.getDefault();
        System.out.print("getDefault:" + aDefault);
        Locale locale = new Locale("");
        locale.clone();
        System.out.print("getDisplay:" + locale.getDisplayCountry());
        System.out.print("getCountry:" + locale.getCountry());
        Locale.Category display = Locale.Category.DISPLAY;
        Locale.FilteringMode autoselectFiltering = Locale.FilteringMode.AUTOSELECT_FILTERING;
        Locale.Category display1 = Locale.Category.DISPLAY;
    }

    public static void main(String[] args) {
        String language, region, script, country, variant;
        language = "";
        region = "89";
        test();
        System.out.println(Locale.Category.DISPLAY + " " + region);


        Locale locale = new Locale("zh_CN");
        //推荐使用，locale实例化 common.lang3包下 zh_CN,en_US
        Locale en_us = LocaleUtils.toLocale("en_US");
        DateFormat dateInstance = DateFormat.getDateInstance(DateFormat.FULL, en_us);
        String formatNum = NumberFormat.getInstance(en_us).format(300200400);
        String format = dateInstance.format(new Date());
        System.out.println("format-date:" + format);
        System.out.println("formatNum:" + formatNum);
        String str = "";
        String substring = str.substring(1);
        System.out.println("substring: " + substring);

    }
}
